#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/unistd.h>
#include <stdio.h>
int main()
{
	char buf[1024];
	int read_byte;
	struct sockaddr_in address;
	int socket_handle;
	int sock;
	socket_handle = socket(AF_INET, SOCK_STREAM, 0);
	
	address.sin_family = AF_INET;
	address.sin_port = htons(3000);
	address.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
	
	bind(socket_handle, (struct sockaddr *) &address, sizeof(address));
	listen(socket_handle, 1);
	accept(socket_handle, NULL, NULL);
	while (true)
	{
		sock = accept(socket_handle, NULL, NULL);
		while (true)
		{
			read_byte = recv(sock, &buf, 1024, 0);
			if (read_byte <= 0) break;
			printf("%s",buf);
		}
		close(sock);
	}
	return 0;	
}
